<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>数据代理-回顾Object.defineProperty</title>
    <script type="text/javascript" src="../../../public/vue.js"></script>
</head>
<body>
<script type="text/javascript">
    let number = 18
    let person = {
        name: '张三',
        sex: '男'
    }
    // Object.defineProperty 控制更加精准
    Object.defineProperty(person, 'age', {
        value: 18,
        enumerable:true// 控制属性是否可以遍历
        ,writable:true // 控制属性是否可以被修改
        ,configurable:true // 控制属性是否可以被删除
        ,get:function (){
            return number
        }
    })
    console.log(person)

</script>
<div id="root">
    姓名：{{ name }}
</div>
</body>
<script type="text/javascript">

    Vue.config.productionTip = false
    const vm = new Vue({
        el: '#root',
        data() {
            return {
                name: '张三'
            }
        }
    })
</script>
</html>